<?php

namespace app\admin\model\oil;

use think\Model;


class Invoice extends Model
{

    // 表名
    protected $name = 'oil_invoice';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text',
    ];

    public function getOrderArrayAttr($value, $data)
    {
        return  json_decode($data['order_array']);
    }

    public function getTypeList()
    {
        return ['1' => __('Type 1'), '2' => __('Type 2')];
    }
    public function getHeaderTypeList()
    {
        return ['1' => __('Header_type 1'), '2' => __('Header_type 2')];
    }
    public function getStatusList()
    {
        return ['normal'=>__('Status Normal'), 'finish'=>__('Status Finish'), 'again'=>__('Status Again'), 'again_finish'=>__('Status Again_finish')];
    }
    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : $data['status'];
        $list = $this->getStatusList();
        return $list[$value] ?? '';
    }




}
